//
//  AXHdzqPdTgTopCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/6.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqPdTgTopCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@interface AXHdzqPdTgTopCell ()
/** 线 */
@property (nonatomic , strong) UIView *lineView;

@end

@implementation AXHdzqPdTgTopCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** 5人团 */
    self.peopleCountLabel = [[UILabel alloc]init];
    self.peopleCountLabel.text = @"5人团";
    self.peopleCountLabel.textAlignment = NSTextAlignmentLeft;
    self.peopleCountLabel.font = FONT_FOURTEEN;;
    self.peopleCountLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.peopleCountLabel];
    /** 已参团*/
    self.nowPeopleLabel = [[UILabel alloc]init];
    self.nowPeopleLabel.text = @"已参团2人";
    self.nowPeopleLabel.font = FONT_FOURTEEN;;
    self.nowPeopleLabel.textColor  = COLOR_GREEN;
    [self.contentView addSubview:self.nowPeopleLabel];
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.image = [UIImage imageNamed:@"pt"];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
  
    /** 产品名字*/
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    self.productNameLabel.font = FONT_TWELVE;
    self.productNameLabel.text = @"夏黑无籽葡萄 1kg装 新鲜水果 ";
    [self.contentView addSubview:self.productNameLabel];
    
    /** 产品价格*/
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.textColor = COLOR_ORG;
    self.priceLabel.font = FONT_TWELVE;
    self.priceLabel.text = @"￥27.99";
    [self.contentView addSubview:self.priceLabel];
 
   
    /** 库存*/
    self.repertoryButton = [[UIButton alloc]init];
    self.repertoryButton.titleLabel.font = FONT_FOURTEEN;;
    self.repertoryButton.backgroundColor = COLOR_ORG;
    [self.repertoryButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.repertoryButton setTitle:@"库存77" forState:UIControlStateNormal];
    [self.contentView addSubview:self.repertoryButton];
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:self.lineView];
    
    
    
}

- (void)setlayout {
    /** 5人参团*/
    self.peopleCountLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(30);
    /** 现在的人数 */
    self.nowPeopleLabel.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(70)
    .autoHeightRatio(0)
    .minHeightIs(40);
    
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.peopleCountLabel, 0)
    .widthIs(80)
    .heightIs(60);
    /* 产品名字 **/
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
   .topEqualToView(self.productImageView)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(30);
    /* 价格 **/
    self.priceLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .topSpaceToView(self.productNameLabel, 0)
    .widthIs(50)
    .heightIs(30);
    /** 库存 */
    self.repertoryButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .widthIs(100)
    .heightIs(30);
    
    
    
    self.lineView.sd_layout
    .rightSpaceToView(self.contentView, 0)
    .topSpaceToView(self.repertoryButton, 10)
    .widthIs(SCREEN_WIDTH)
    .heightIs(10);
    
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:10];
    
}

@end

